package cn.imu.servlet;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "LoginOutServlet", value = "/LoginOutServlet")
public class LoginOutServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //消除session
        HttpSession session=request.getSession();
        //删除自己放到session中的数据
        session.removeAttribute("user");
        session.invalidate();

      /*  //清除cookie,并退出
        Cookie[] cookies=request.getCookies();
        for(Cookie cookie:cookies){
            cookie.setMaxAge(0);
            response.addCookie(cookie);
        }*/
        System.out.println("访问到LoginOutServlet。。。。");
        response.sendRedirect("Login.jsp");
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
